Dynomotion

Group: DynoMotion Message: 2356 From: jason13086 Date: 11/20/2011
Subject: Need recompiled DLL to use with LabVIEW
Hi all,

I'm using a KFLOP controller to control a tabletop gantry positioning system. I'm using LabVIEW to control it through the serial interface, however the feedback is a little bit too slow: it takes about 0.26 seconds to query the position. I've tried increasing the baud rate to 115.2k but that doesn't appreciably reduce the time it takes to do a query.

I noticed the KMotionCNC program appears to be much faster, presumably because it's using the DLL. LabVIEW can also communicate with DLLs, however, it doesn't support DLLs compiled in C++ because of the name mangling that occurs.

The solution is to get a DLL recompiled with extern "C" statements. This will create a DLL which external programs can use more easily. There shouldn't be any issue with putting in the extern "C" statement in that would impact any other part of the existing software.

Here is more details on the extern statement:
http://zone.ni.com/devzone/cda/tut/p/id/3056#toc2

Here's another small section on it:
http://zone.ni.com/devzone/cda/tut/p/id/3341#toc4
http://zone.ni.com/devzone/cda/tut/p/id/3341#toc8

The C++ name decorations are needed if there are polymorphic functions. But if this DLL is composed of just simple functions, there should be no need for it.

If I get it working, I can share some labview examples here on this forum. This could be very helpful to others in the future. LabVIEW is a widely used tool.

Thanks,
Jason
Group: DynoMotion Message: 2357 From: Tom Kerekes Date: 11/20/2011
Subject: Re: Need recompiled DLL to use with LabVIEW
Hi Jason,
 
I think that is exactly what our KMviaVB.dll does.  It is just a wrapper around the C++ KMotionDLL.dll that exports the functions as straight C functions.
 
Also the KMotion_dotNet_Interop does this also and exposes more of the C++ classes.
 
Have you tried those?
 
Regards
TK
 
 

Group: DynoMotion Message: 2362 From: Brad Murry Date: 11/20/2011
Subject: Re: Need recompiled DLL to use with LabVIEW

Jason,

 

The KMotion_dotNet_Interop project has the exact decorations on the export functions you are asking.  They will be handled as traditional C calls without the oddly decorated functions imported on the CLR side.

 

It will import cleanly.

 

The KMviaVB does not have the C export decorations(and they should maybe be added) so it is probable you will have a hard time wiring up your wrappers without using a tool to discover the actual export calls.

 

-Brad Murry

 

From: DynoMotion@yahoogroups.com [mailto:DynoMotion@yahoogroups.com] On Behalf Of Tom Kerekes
Sent: Sunday, November 20, 2011 6:36 PM
To: DynoMotion@yahoogroups.com
Subject: Re: [DynoMotion] Need recompiled DLL to use with LabVIEW

 

 

Hi Jason,

 

I think that is exactly what our KMviaVB.dll does.  It is just a wrapper around the C++ KMotionDLL.dll that exports the functions as straight C functions.

 

Also the KMotion_dotNet_Interop does this also and exposes more of the C++ classes.

 

Have you tried those?

 

Regards

TK

 

 

 

From: jason13086 <jason13086@...>
To: DynoMotion@yahoogroups.com
Sent: Sunday, November 20, 2011 5:13 PM
Subject: [DynoMotion] Need recompiled DLL to use with LabVIEW

 

Hi all,

I'm using a KFLOP controller to control a tabletop gantry positioning system. I'm using LabVIEW to control it through the serial interface, however the feedback is a little bit too slow: it takes about 0.26 seconds to query the position. I've tried increasing the baud rate to 115.2k but that doesn't appreciably reduce the time it takes to do a query.

I noticed the KMotionCNC program appears to be much faster, presumably because it's using the DLL. LabVIEW can also communicate with DLLs, however, it doesn't support DLLs compiled in C++ because of the name mangling that occurs.

The solution is to get a DLL recompiled with extern "C" statements. This will create a DLL which external programs can use more easily. There shouldn't be any issue with putting in the extern "C" statement in that would impact any other part of the existing software.

Here is more details on the extern statement:
http://zone.ni.com/devzone/cda/tut/p/id/3056#toc2

Here's another small section on it:
http://zone.ni.com/devzone/cda/tut/p/id/3341#toc4
http://zone.ni.com/devzone/cda/tut/p/id/3341#toc8

The C++ name decorations are needed if there are polymorphic functions. But if this DLL is composed of just simple functions, there should be no need for it.

If I get it working, I can share some labview examples here on this forum. This could be very helpful to others in the future. LabVIEW is a widely used tool.

Thanks,
Jason

 

Group: DynoMotion Message: 2364 From: jason13086 Date: 11/20/2011
Subject: Re: Need recompiled DLL to use with LabVIEW
Thanks, I'll try these out and report back.

--- In DynoMotion@yahoogroups.com, Brad Murry <bradodarb@...> wrote:
>
> Jason,
>
>
>
> The KMotion_dotNet_Interop project has the exact decorations on the export functions you are asking. They will be handled as traditional C calls without the oddly decorated functions imported on the CLR side.
>
>
>
> It will import cleanly.
>
>
>
> The KMviaVB does not have the C export decorations(and they should maybe be added) so it is probable you will have a hard time wiring up your wrappers without using a tool to discover the actual export calls.
>
>
>
> -Brad Murry
>
>
>
> From: DynoMotion@yahoogroups.com [mailto:DynoMotion@yahoogroups.com] On Behalf Of Tom Kerekes
> Sent: Sunday, November 20, 2011 6:36 PM
> To: DynoMotion@yahoogroups.com
> Subject: Re: [DynoMotion] Need recompiled DLL to use with LabVIEW
>
>
>
>
>
> Hi Jason,
>
>
>
> I think that is exactly what our KMviaVB.dll does. It is just a wrapper around the C++ KMotionDLL.dll that exports the functions as straight C functions.
>
>
>
> Also the KMotion_dotNet_Interop does this also and exposes more of the C++ classes.
>
>
>
> Have you tried those?
>
>
>
> Regards
>
> TK
>
>
>
>
>
>
>
> From: jason13086 <jason13086@...>
> To: DynoMotion@yahoogroups.com
> Sent: Sunday, November 20, 2011 5:13 PM
> Subject: [DynoMotion] Need recompiled DLL to use with LabVIEW
>
>
>
> Hi all,
>
> I'm using a KFLOP controller to control a tabletop gantry positioning system. I'm using LabVIEW to control it through the serial interface, however the feedback is a little bit too slow: it takes about 0.26 seconds to query the position. I've tried increasing the baud rate to 115.2k but that doesn't appreciably reduce the time it takes to do a query.
>
> I noticed the KMotionCNC program appears to be much faster, presumably because it's using the DLL. LabVIEW can also communicate with DLLs, however, it doesn't support DLLs compiled in C++ because of the name mangling that occurs.
>
> The solution is to get a DLL recompiled with extern "C" statements. This will create a DLL which external programs can use more easily. There shouldn't be any issue with putting in the extern "C" statement in that would impact any other part of the existing software.
>
> Here is more details on the extern statement:
> http://zone.ni.com/devzone/cda/tut/p/id/3056#toc2
>
> Here's another small section on it:
> http://zone.ni.com/devzone/cda/tut/p/id/3341#toc4
> http://zone.ni.com/devzone/cda/tut/p/id/3341#toc8
>
> The C++ name decorations are needed if there are polymorphic functions. But if this DLL is composed of just simple functions, there should be no need for it.
>
> If I get it working, I can share some labview examples here on this forum. This could be very helpful to others in the future. LabVIEW is a widely used tool.
>
> Thanks,
> Jason
>
Group: DynoMotion Message: 2371 From: jason13086 Date: 11/21/2011
Subject: Re: Need recompiled DLL to use with LabVIEW
When using the .net interop, how do I get a handle? Every function requires one.
Group: DynoMotion Message: 2372 From: Tom Kerekes Date: 11/21/2011
Subject: Re: Need recompiled DLL to use with LabVIEW
Hi Jason,
 
I think you need to call:
 
extern
"C" __declspec(dllexport) int __stdcall KM_dotnet_Interop_New(int *handle);
 
or
 
KM_dotnet_Interop_New(ref _InstanceHandle);

 
Regards
TK
 
 
Group: DynoMotion Message: 2375 From: bradodarb Date: 11/21/2011
Subject: Re: Need recompiled DLL to use with LabVIEW
Are you using the Call Library Function Node?

Like here?::
http://zone.ni.com/devzone/cda/tut/p/id/4877#toc4


You should be able to browse to the KMotion_dotNet_Interop.dll, and all availble function calls should be available in the drop down.



-Brad Murry

--- In DynoMotion@yahoogroups.com, "jason13086" <jason13086@...> wrote:
>
> When using the .net interop, how do I get a handle? Every function requires one.
>
Group: DynoMotion Message: 2393 From: jason13086 Date: 11/21/2011
Subject: Re: Need recompiled DLL to use with LabVIEW
I'm able to import the .net version of the dll, but when I run the int__stdcallKM_dotnet_Interop_New(int*handle); function it gives me the error message shown here:
http://i.imgur.com/HYAHz.png

"Unable to execute KMotionServer.exe"

Any idea why it's not working? This happens even after I reboot my PC. I'm calling the .net interop dll in its native directory. The labview code is here for anyone interested:
http://www.filedropper.com/dll_2


--- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@...> wrote:
>
> Hi Jason,
>  
> I think you need to call:
>  extern"C"__declspec(dllexport) int__stdcallKM_dotnet_Interop_New(int*handle);
>  
> or
>  
> KM_dotnet_Interop_New(ref_InstanceHandle);
>  
> Regards
> TK
>  
>  
> From: jason13086 <jason13086@...>
> To: DynoMotion@yahoogroups.com
> Sent: Monday, November 21, 2011 9:47 AM
> Subject: [DynoMotion] Re: Need recompiled DLL to use with LabVIEW
>
>
>  
> When using the .net interop, how do I get a handle? Every function requires one.
>
Group: DynoMotion Message: 2395 From: TK Date: 11/22/2011
Subject: Re: Need recompiled DLL to use with LabVIEW
Hi Jason,

Try adding <Install Dir>\KMotion\Release which is where the KMotionServer.exe is to your Windows Path.

Regards
TK

On Nov 21, 2011, at 8:55 PM, "jason13086" <jason13086@...> wrote:

 

I'm able to import the .net version of the dll, but when I run the int__stdcallKM_dotnet_Interop_New(int*handle); function it gives me the error message shown here:
http://i.imgur.com/HYAHz.png

"Unable to execute KMotionServer.exe"

Any idea why it's not working? This happens even after I reboot my PC. I'm calling the .net interop dll in its native directory. The labview code is here for anyone interested:
http://www.filedropper.com/dll_2

--- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@...> wrote:
>
> Hi Jason,
>  
> I think you need to call:
>  extern"C"__declspec(dllexport) int__stdcallKM_dotnet_Interop_New(int*handle);
>  
> or
>  
> KM_dotnet_Interop_New(ref_InstanceHandle);
>  
> Regards
> TK
>  
>  
> From: jason13086 <jason13086@...>
> To: DynoMotion@yahoogroups.com
> Sent: Monday, November 21, 2011 9:47 AM
> Subject: [DynoMotion] Re: Need recompiled DLL to use with LabVIEW
>
>
>  
> When using the .net interop, how do I get a handle? Every function requires one.
>